import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, ManyToMany, ManyToOne, JoinColumn, OneToOne, UpdateDateColumn, Generated, RelationId, JoinTable } from "typeorm"
import { My,Staff} from "../../my/entities/my.entity"

@Entity()

export class Works {

    @PrimaryGeneratedColumn({ type: "int" })
    id: number

    @Column({ type: "text" })
    content: string
    @Column({ type: "text" })
    image: string
    @Column({ type: "text" })
    video: string
    @Column({ type: "int" })
    type: number

    @CreateDateColumn({ type: "timestamp" })
    createTime: Date
    @Column({ type: "varchar", length: 200 })
    site: string
    @Column({ type: "int",foreignKeyConstraintName:"id"})
    userId: number
    @Column({ type: "int" ,default:0})
    worksLimit: number
    @Column({ type: "int",default:0})
    examine: number
    @Column({ type: "varchar", length: 50,default:0 })
    sort: string
    @Column({ type: "varchar", length: 200 })
    taskId: string
    @Column({ type: "varchar", length: 100 ,default:0})
    teamId: string
    @Column({type:"varchar",length:100,default:0})
    state:string
    @Column({type:"varchar",default:0})
    taskPersonId:string

    // @UpdateDateColumn()
    // @Generated()
    // @Column({type:"varchar",nullable:false})
    @ManyToOne((type)=>My,(my) => my.works,{eager:true,cascade:true})
    @JoinColumn({name:"userId",referencedColumnName:"id"})
    my: My

    @OneToOne((tyep)=>Staff,{createForeignKeyConstraints:false})
    staff:Staff
    // @RelationId((works:Works)=>works.my)
    // userinfo_id:number

}